package com.xxbing.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import com.github.pagehelper.PageInfo;
import com.xxbing.dto.EdocEntryDto;
import com.xxbing.model.EdocCategory;
import com.xxbing.model.EdocEntry;
import com.xxbing.service.EdocCategoryService;
import com.xxbing.service.EdocEntryService;

@Controller
@RequestMapping("/")
public class MainShowController {
	
	@Autowired
	private EdocEntryService edocEntryService;
	
	@Autowired
	private EdocCategoryService edocCategoryService;
	
//	@RequestMapping("/")
//	public String edocEntryList(Model model) {
//		List<EdocEntry> edocEntry = edocEntryService.selectAll();
//		model.addAttribute("edocEntries", edocEntry);
//		
//		List<EdocCategory> edocCategory = edocCategoryService.selectAll();
//		model.addAttribute("edocCategory", edocCategory);
//		return "main";
//	}
	
	
	@RequestMapping("/")
	public String edocEntryList(Model model) {
		PageInfo pageInfo = edocEntryService.selectByAll();
		List<EdocEntry> edocEntries = pageInfo.getList();
		model.addAttribute("edocEntries", edocEntries);
		model.addAttribute("pageInfo", pageInfo);
		List<EdocCategory> edocCategory = edocCategoryService.selectAll();
		model.addAttribute("edocCategory", edocCategory);
		model.addAttribute("select_val", -1);
		return "main";
	}
}
